import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store/index'
const Topic = () => import('../views/topic/topic')
const Home = () => import('../views/home/home.vue')
const Shop = () => import('../views/shop/shop.vue')
const Live = () => import('../views/live/live.vue')
const Car = () => import('../views/car/car.vue')
const Mine = () => import('../views/mine/mine.vue')
const Login = () => import('../views/login/login.vue')
const Register = () => import('../views/register/register.vue')
const Position = () => import('../views/home/position.vue')
const OrCenter = () => import('../views/orCenter/orCenter.vue')
const Person = () => import('../views/person/person.vue')
const Address = () => import('../views/address/address.vue')
const Collage = () => import('../views/collage/collage.vue')
const Customer = () => import('../views/customer/customer.vue')
const Setup = () => import('../views/setup/setup.vue')
const Opinion = () => import('../views/opinion/opinion.vue')
const News = () => import('../views/news/news.vue')
const NewAddress = () => import('../views/newAddress/newAddress.vue')
const Nine = () => import('../views/home/part/nine.vue')
const Together = () => import('../views/home/part/together.vue')
const RedBag = () => import('../views/redBag/redBag.vue')
const Integral = () => import('../views/integral/integral.vue')
const Balance = () => import('../views/balance/balance.vue')
const Coupon = () => import('../views/car/coupon.vue')
const Coldetail = () => import('../views/collage/coldetail.vue')
const Setpassword = () => import('../views/setup/setpassword')
const Userxy = () => import('../views/setup/userxy')
const Aboutas = () => import('../views/setup/aboutas')
const Yijian = () => import('../views/setup/yijian')
const Manage = () => import('../views/car/manage.vue')
const Fail = () => import('../views/car/fail')
const Success = ()=>import('../views/car/success.vue')
const Nhk = ()=>import('../views/car/nhk.vue')
const Nonuse = ()=>import('../views/car/nonuse.vue')
const Detail = ()=>import('../views/live/details.vue')
const cityList = ()=>import('../views/home/part/citylist.vue')
const EditAddress = ()=>import('../views/editAddress/editAddress.vue')
const newShare = ()=>import('../views/home/part/newshare.vue')
Vue.use(VueRouter)

export const routes = [
  // {
  //   path: '/newShare',
  //   component: newShare,
  //   name: 'newShare',
  //   isHidden: true,
  //   meta: {
  //     til: "新人专享"
  //   }
  // },
  {
    path: '/city',
    component: cityList,
    name: 'city',
    isHidden: true,
    meta: {
      til: "城市"
    }
  },
  {
    path: '/yijian',
    component: Yijian,
    name: 'yijian',
    isHidden: true,
    meta: {
      til: "意见反馈",
      icon: 'el-icon-s-home'
    }
  },
  {
    path: '/userxy',
    component: Userxy,
    name: 'userxy',
    isHidden: true,
    meta: {
      til: "用户协议",
      icon: 'el-icon-s-home'
    }
  },
  {
    path: '/aboutas',
    component: Aboutas,
    name: 'aboutas',
    isHidden: true,
    meta: {
      til: "关于我们",
      icon: 'el-icon-s-home'
    }
  },
  {
    path: '/setpassword',
    component: Setpassword,
    name: 'setpassword',
    isHidden: true,
    meta: {
      til: "修改密码",
      icon: 'el-icon-s-home'
    }
  },
  {
    path: '/topic:pid',
    component: Topic,
    name: 'topic',
    isHidden: true,
    meta: {
      til: "商品详情"
    }
  },
  {
    path: '/',
    component: Home,
    name: 'Home',
    isHidden: false,
    meta: {
      til: "首页",
      icon: 'el-icon-s-home',
      index: 0
    }
  },
  {
    path: '/shop',
    component: Shop,
    isHidden: false,
    meta: {
      til: "商城",
      icon: 'el-icon-menu',
      index: 1
    }
  },
  {
    path: '/live',
    component: Live,
    isHidden: false,
    index: 2,
    meta: {
      til: "视频",
      icon: 'el-icon-video-camera-solid',
      index: 2
    }
  },
  {
    path: '/car',
    component: Car,
    isHidden: false,
    meta: {
      til: "购物车",
      icon: 'el-icon-s-finance',
      index: 3
    }
  },
  {
    path: '/mine',
    component: Mine,
    isHidden: false,
    meta: {
      til: "我的",
      icon: 'el-icon-user-solid',
      index: 4
    }
  },
  {
    path: '/login',
    component: Login,
    name: 'Login',
    isHidden: true,
    meta: {
      til: "登录"
    }
  },
  {
    path: '/register',
    component: Register,
    name: 'register',
    isHidden: true,
    meta: {
      til: "注册"
    }
  },

  //视频详情页
  {
    path: '/detali',
    component: Detail,
    name: 'detali',
    isHidden: true,
    meta: {
      til: "视频"
    }
  },
  {
    path: '/manage',
    component: Manage,
    name: 'manage',
    isHidden: true,
    meta: {
      til: "管理"
    }
  },
  {
    path: '/fail',
    component: Fail,
    name: 'fail',
    isHidden: true,
    meta: {
      til: "支付失败"
    }
  },
  {
    path: '/success',
    component: Success,
    name: 'success',
    isHidden: true,
    meta: {
      til: "支付成功"
    }
  },
  {
    path: '/nhk',
    component: Nhk,
    name: 'nhk',
    isHidden: true,
    meta: {
      til: "填写订单(使用优惠)"
    }
  },
  {
    path: '/nonuse',
    component: Nonuse,
    name: 'nonuse',
    isHidden: true,
    meta: {
      til: "填写订单"
    }
  },
  {
    path: '/coupon',
    component: Coupon,
    name: 'coupon',
    isHidden: true,
    meta: {
      til: "优惠券"
    }
  },
  {
    path: '/position',
    component: Position,
    name: 'position',
    isHidden: true,
    meta: {
      til: "定位"
    },
  },
  {
    path: '/orCenter',
    component: OrCenter,
    name: 'orCenter',
    isHidden: true,
    meta: {
      til: "订单中心"
    }
  },
  {
    path: '/address',
    component: Address,
    name: 'address',
    isHidden: true,
    meta: {
      til: "收货地址"
    }
  },
  {
    path: '/collage',
    component: Collage,
    name: 'collage',
    isHidden: true,
    meta: {
      til: "我的拼团"
    }
  },
  {
    path: '/customer',
    component: Customer,
    name: 'customer',
    isHidden: true,
    meta: {
      til: "客服咨询"
    }
  },
  {
    path: '/setup',
    component: Setup,
    name: 'setup',
    isHidden: true,
    meta: {
      til: "设置"
    }
  },
  {
    path: '/opinion',
    component: Opinion,
    name: 'opinion',
    isHidden: true,
    meta: {
      til: "意见反馈"
    }
  },
  {
    path: '/person',
    component: Person,
    name: 'person',
    isHidden: true,
    meta: {
      til: "个人资料"
    }
  },
  {
    path: '/news',
    component: News,
    name: 'news',
    isHidden: true,
    meta: {
      til: "消息中心"
    }
  },
  {
    path: '/newAddress',
    component: NewAddress,
    name: 'newAddress',
    isHidden: true,
    meta: {
      til: "新增地址"
    }
  },
  {
    path: '/nine',
    component: Nine,
    name: 'nine',
    isHidden: true,
    meta: {
      til: "9块9特卖"
    }
  },
  {
    path: '/together',
    component: Together,
    name: 'together',
    isHidden: true,
    meta: {
      til: "一元拼团"
    }
  },
  {
    path: '/redBag',
    component: RedBag,
    name: 'redBag',
    isHidden: true,
    meta: {
      til: "红包"
    }
  },
  {
    path: '/integral',
    component: Integral,
    name: 'integral',
    isHidden: true,
    meta: {
      til: "积分"
    }
  },
  {
    path: '/balance',
    component: Balance,
    name: '/balance',
    isHidden: true,
    meta: {
      til: "余额"
    }
  },
  {
    path: '/coupon',
    component: Coupon,
    name: '/coupon',
    isHidden: true,
    meta: {
      til: "优惠券"
    }
  },
  {
    path: '/coldetail',
    component: Coldetail,
    name: 'coldetail',
    isHidden:true,
    meta:{
     til:"拼团中"
    }
  },
	 {
    path: '/editAddress',
    component:EditAddress,
    name: 'editAddress',
    isHidden:true,
    meta:{
     til:"修改地址"
    }
  },
  
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  // console.log(to)
  document.title = to.meta.til
  store.commit("setIndex", to.meta.index);
  console.log(store.state)
  if (to.query.novalidate) {
    next()
    return
  }
  next()

})

export default router
